//
//  SwiftBlock.swift
//  SwiftTool
//
//  Created by 红沙尘 on 2018/11/4.
//  Copyright © 2018年 红沙尘. All rights reserved.
//

import UIKit

class SwiftBlock: NSObject {

    
    //MARK: - 不带参数且也不带返回值
    class func fun1(completon:@escaping() -> ()) {
        completon()
    }
    
    //MARK: - 带参数但是不带返回值
    class func fun2(completion:@escaping(_ result:String) -> ()) {
        completion("带一个String类型参数");
    }
    
    class func fun3(a:Int, b:Int, complteion:@escaping(_ result:Int) -> ()) {
        complteion(a+b)
    }
    
    class func fun3_1(complteion:@escaping(_ result:Int, _ error: NSError) -> ()) {
        complteion(1,NSError())
    }
    
    //MARK: - 带参数且带返回值
    class func fun4(a:Int, b:Int, complteion:@escaping(_ result:Int) -> Int) {
        let sum = complteion(a+b)
        print(sum)
    }
}
